package com.geekbang.rpcfx.demo.consumer;

import com.geekbang.rpcfx.client.Rpcfx;
import com.geekbang.rpcfx.client.call.OkHttpCallImpl;
import com.geekbang.rpcfx.client.call.RpcCall;
import com.geekbang.rpcfx.demo.api.entity.Order;
import com.geekbang.rpcfx.demo.api.service.OrderService;
import com.geekbang.rpcfx.demo.api.entity.User;
import com.geekbang.rpcfx.demo.api.service.UserService;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SpringBootApplication
public class RpcfxClientApplication {

    public static void main(String[] args) {

        RpcCall rpcCall = new OkHttpCallImpl();

        UserService userService = Rpcfx.create(UserService.class, "http://localhost:8080/", rpcCall);
        User user = userService.findById(1);
        System.out.println("find user id=1 from server: " + user.getName());

        OrderService orderService = Rpcfx.create(OrderService.class, "http://localhost:8080/", rpcCall);
        Order order = orderService.findOrderById(1992129);
        System.out.println(String.format("find order name=%s, amount=%f", order.getName(), order.getAmount()));

    }

}



